﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Configuration;
using System.Text;
using System.Collections;
using System.Data.OracleClient;
using Xiaov.SmartWeb.Application.SupCan;

namespace Xiaov.SmartWeb.Application.HXZB.Tzfx
{
    public partial class XmyxdbData : System.Web.UI.Page
    {

        protected void Page_Load(object sender, EventArgs e)
        {
            string dataString = ConfigurationManager.AppSettings["Xmyxdb_Column"];
            int nf = DateTime.Now.Year;
            int yf = DateTime.Now.Month;
            if (Request.QueryString["nf"] != "" && Request.QueryString["yf"] != "")
            {
                nf = Convert.ToInt32(Request.QueryString["nf"]);
                yf = Convert.ToInt32(Request.QueryString["yf"]);
            }
            string sSql = "select b.jh jh," + dataString + @"
                from v_cj_yt_tzzb a left join zjyb_zjyb00 b on trim(a.zbmc)=trim(b.jh)                 
                where a.nf =" + nf + " and a.yf=" + yf + " and a.xmgcid_lb='工程' order by a.pxbm";
            DataSet ds = Maticsoft.DBUtility.DbHelperOra.Query(sSql);
            ds.Tables[0].Columns.Add("tzcj3", Type.GetType("System.String"));
            ds.Tables[0].Columns.Add("tzcj4", Type.GetType("System.String"));
            ds.Tables[0].Columns.Add("tzcj5", Type.GetType("System.String"));
            ds.Tables[0].Columns.Add("tzcj6", Type.GetType("System.String"));
            if (ds != null && ds.Tables[0].Rows.Count > 0)
            {
                foreach (DataRow dr in ds.Tables[0].Rows)
                {
                    string[] lb = dr["pxbm"].ToString().Split('_');
                    if (lb.Length > 0)
                    {
                        if (lb[0].Length >= 10)
                        {
                            dr["tzcj6"] = lb[0].Substring(0, 10);
                        }
                        if (lb[0].Length >= 8)
                        {
                            dr["tzcj5"] = lb[0].Substring(0, 8);
                        }
                        if (lb[0].Length >= 6)
                        {
                            dr["tzcj4"] = lb[0].Substring(0, 6);
                        }
                        if (lb[0].Length >= 4)
                        {
                            dr["tzcj3"] = lb[0].Substring(0, 4);
                        }
                    }
                }
            }
           
            #region 输出xml串
            ConvertToXml.Convert(ds.Tables[0], dataString + ",tzcj3,tzcj4,tzcj5,tzcj6,jh", 0, ds.Tables[0].Rows.Count);
            #endregion
        }     
    }
}